---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source_code: embed
---
```{r setup, message = FALSE, echo = FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
library(readxl)
```
```{r, include=FALSE}
ghed_df <-
read_excel("./data/GHED_data.XLSX")
ghed_df<-ghed_df %>%
janitor::clean_names()
```
Column {data-width=500}
-----------------------------------------------------------------------
### Private vs. Government Expenditure in Developed Countries in 2019
```{r}
ghed_df%>%
filter(country=="Canada"| country=="Japan"| country=="Republic of Korea"| country=="France"| country=="Germany"| country=="Italy"| country=="United Kingdom"| country=="United States of America")%>%
filter(year == 2019)%>%
select(country, year, gghed_che, pvtd_che)%>%
mutate(sum_per = gghed_che + pvtd_che)%>%
pivot_longer(cols = contains("che"),
names_to = "exp_type",
values_to = "exp_per")%>%
mutate(exp_type = replace(exp_type, exp_type == "gghed_che", "Government Expenditure"),
exp_type = replace(exp_type, exp_type == "pvtd_che", "Private Expenditure"))%>%
plot_ly(x=~country, y=~exp_per, name=~exp_type, color =~exp_type, type = 'bar', colors = "viridis")%>%
layout(yaxis = list(title = 'Percent of Total Expenditure'), xaxis = list(title = "Country", categoryorder = "total descending"), barmode = 'stack', colors = "viridis")
```
Column {data-width=500}
-----------------------------------------------------------------------
### Out-of-pocket spending as % of Current Health Expenditure
```{r}
developed_nations%>%
filter(year==2019)%>%
select(country, oops_che)%>%
arrange(desc(oops_che))%>%
plot_ly(x=~country, y=~oops_che, name=~country, color =~country, type = 'bar', colors = "viridis")%>%
layout(yaxis = list(title = 'Out-of-pocket (OOPS) as % of Current Health Expenditure'), xaxis = list(title = "Country"), barmode = 'stack', colors = "viridis")%>%
layout(xaxis = list(categoryorder = "total descending"))
```
### Social Health Insurance as % of Current Health Expenditure
```{r}
developed_nations%>%
filter(year==2019)%>%
select(country, shi_che)%>%
arrange(desc(shi_che))%>%
plot_ly(x=~country, y=~shi_che, name=~country, color =~country, type = 'bar', colors = "viridis")%>%
layout(yaxis = list(title = 'Social Health Insurance (SHI) as % of Current Health Expenditure (CHE)'), xaxis = list(title = "Country"), barmode = 'stack', colors = "viridis")%>%
layout(xaxis = list(categoryorder = "total descending"))
```
Social Health Insurance as % of Current Health Expenditure